﻿using Domain.Examin;
using MediatR;
using MES.Server.API.Application.Command.ApprovalProcess;
using MES.Server.API.Dto.ApprovalProcess;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using ReturnValue;

namespace MES.Server.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ApprocalProcessController : ControllerBase
    {
        private readonly IMediator mediator;

        public ApprocalProcessController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 获取审批节点
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<ApprovalNodeModel>>> GetApprovalNodes([FromQuery]GetApprovalNodeCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 批量保存流程节点配置
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> ConfigurationNode(ConfigurationNodeCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 查询配置节点
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<ApprovalNodeDTO>>> GetConfigurationNode([FromQuery]GetConfigurationNodeCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 流程审批
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<bool>> ApprovalPurchaseOrders([FromBody]ApprovalPurchaseOrderCommand request)
        {
            return await mediator.Send(request);
        }
    }
}
